var express = require('express')

var goodRouter = express.Router()

goodRouter.get('/list', (req, res) => {
    var {
        page,
        count
    } = req.query;
    var newarr = arr.slice((page - 1) * count, page * count);
    res.send({
        code: 200,
        msg: '请求成功!',
        list: newarr
    });

})

goodRouter.get('/search', (req, res) => {
    var {
        searchkey
    } = req.query;
    var newarr = arr.filter((item) => {
        return new RegExp(searchkey).test(item.name)
    })
    res.send({
        code: 200,
        msg: '查询成功!',
        list: newarr
    })
})

module.exports = goodRouter;